<html>
<head>
	<title>DELETE Items</title>
</head>
<body style="font-family:consolas;">
	<form onSubmit="doNewRequest();"></form>
	<table width="100%">
	<tr>
	<td>Files</td>
	</tr>
	<tr>
	<td><textarea id="fileList" style="width: 100%; height: 300px;"></textarea></td>
	</tr>
	</table>
	<br />
<button onClick="doNewRequest();" value="XHR">Execute</button>
	<br /><br/>
	Response<br />
	<textarea id="output" style="width: 90%; height: 400px;"></textarea>
	<br />
	<button onclick="clearOutput()">
		Clear output</button>
</body>
<script type="text/javascript">
	var req;
	var output = document.getElementById("output");

	function clearOutput() {
		output.innerHTML = "";
	}
	function processReqChange() {
		if (req.readyState == 4) {
			try {
			output.innerHTML += req.status + " " + req.statusText + "\n";
			} catch(err) {
			output.innerText += "Error -- " + req.responseText;
			}
		}
	}
	function doNewRequest() {
		var actionUris = document.getElementById("fileList").value.replace("\r","").split("\n");

		var cnt = actionUris.length;
		
		for (var i=0;i < cnt; i++) {
			req = new XMLHttpRequest();
			output.innerHTML = "Deleting (" + (i+1) + " of " + cnt + ") '" + actionUris[i] + "'\n";
			//req.onreadystatechange = processReqChange;
			req.open("DELETE", actionUris[i], false);
			req.send();
			
			try {
				output.innerHTML += req.status + " " + req.statusText + "\n";
			} catch(err) {
				output.innerText += "Error -- " + req.responseText + output.innerHTML;
			}
		}
		return false;
	}

</script>
</html>
